package xjtu.zd.server.book.detail.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import xjtu.zd.server.book.detail.Detail;
import xjtu.zd.server.book.detail.ScoDto;
import xjtu.zd.server.common.CurrentUser;

public interface DetailDao {

    @Select("select * from t_book,t_user,t_class " +
            "where t_book.u_id = t_user.u_id " +
            "and t_book.cla_id = t_class.cla_id " +
            "and b_id = #{b_id}")
    Detail getInfo(@Param("b_id")int b_id);

    @Insert("insert into t_score values(#{u_id}, #{b_id}, #{score})")
    void setScore(ScoDto dto);

    @Select("select sum(score)/count(score) from t_score where b_id = #{b_id}")
    float getScore(String b_id);
}
